import { checkStr } from '@/utils/judge'
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t('common.add'),
    type: 'primary',
    icon: 'el-icon-circle-plus-outline',
    handleName: 'add' //点击时返回的标识
  },
  {
    name: $i18n.t('common.delete'),
    type: 'danger',
    icon: 'el-icon-delete',
    handleName: 'deleteBatch', //点击时返回的标识
    isMultiple: true
  }
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t('common.edit'),
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'edit' //点击时返回的标识
  },
  {
    name: $i18n.t('common.details'),
    type: 'info',
    class: 'row-btn-info',
    handleName: 'detail' //点击时返回的标识
  },
  {
    name: $i18n.t('common.delete'),
    type: 'danger',
    class: 'row-btn-danger',
    handleName: 'delete' //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    skillCode: {
      type: 'input',
      label: $i18n.t('mesSkill.skillCode')
    },
    skillName: {
      type: 'input',
      label: $i18n.t('mesSkill.skillName')
    }
    // factoryCode: {
    //   type: "input",
    //   label: "工厂编码",
    // },
  }
}
var validatePass = (rule, value, callback) => {
  setTimeout(() => {
    if (!checkStr(value, 'english-number')) {
      callback(new Error($i18n.t('mesSkill.rule8')))
    } else {
      callback()
    }
  }, 100)
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  rules: {
    skillCode: [{ validator: validatePass, trigger: ['change', 'blur'] }]
  },
  formDesc: {
    skillCode: {
      type: 'input',
      label: $i18n.t('mesSkill.skillCode'),
      layout: 12,
      disabled: (d) => !!d.id,
      required: true
    },
    skillName: {
      type: 'input',
      label: $i18n.t('mesSkill.skillName'),
      layout: 12,
      required: true
    },
    // factoryCode: {
    //   type: "input",
    //   label: "工厂编码",
    //   layout: 12,
    //   required: true,
    // },
    remark: {
      type: 'textarea',
      label: $i18n.t('common.remark'),
      layout: 24,
      required: false
    }
  }
}
